<?php
include_once 'MySQLDAO.php';

/**
 * Definition of Class Paymentmethods
 * This class represents a data access object for the database table 'paymentmethods'.
 */
class Paymentmethods {


	public $dao = null;

	private $i = 1;

	/**
	 * associated database field: paymentMethodId, type: int, is nullable: false
	 */
	private $paymentMethodId  = 0;

	/**
	 * associated database field: paymentMethod, type: varchar, is nullable: true, character set: utf8, max length: 45
	 */
	private $paymentMethod;



	/**
	 * Default constructor
	 * @param value some value
	 */
	function __construct(){
		$this->dao = new MySQLDao("PaymentMethods");
	}


	/**
	 * Initialize the business object with data read from the DB.
	 * @param row database row array containing the values from one read record
	 */
	public function init($row){
		if(isset($row['paymentMethodId'])) $this->paymentMethodId = $row['paymentMethodId'];
		if(isset($row['paymentMethod'])) $this->paymentMethod = $row['paymentMethod'];
	}


	/**
	 * Returns the string representation for this object
	 * @param escapeQuotationMarks boolean value to indicate if quotation marks in value strings should be escaped, default value is true
	 * @return String String representation of Paymentmethods
	 */
	public function toString($escapeQuotationMarks=true){
		$s = '[';
		$s .= 'paymentMethodId: '.(($escapeQuotationMarks===true) ? addslashes($this->paymentMethodId) : $this->paymentMethodId).', ';
		$s .= 'paymentMethod: '.(($escapeQuotationMarks===true) ? addslashes($this->paymentMethod) : $this->paymentMethod);
		$s .= ']';
		return $s;
	}


	/**
	 * Returns the JSON (JavaScript Object Notation) string representation for this object
	 * @return String JSON representation of Paymentmethods
	 */
	public function toJSONString(){
		$fieldValues = array ("paymentMethodId"=>$this->paymentMethodId, "paymentMethod"=>$this->paymentMethod);
		return json_encode($fieldValues);
	}


	/**
	 * Returns a HTML representation of this object using DIVs for formatting via css
	 * @param escapeHTML boolean value to indicate if value strings should be html escaped, default value is true
	 * @return String the HTML representation of the Paymentmethods object
	 */
	public function toHTMLString($escapeHTML=true){
		$htmlCode = "<div class=\"paymentmethods\">\n";
		$htmlCode .= '	<div class="paymentmethods_paymentMethodId">'.(($escapeHTML===true) ? htmlspecialchars($this->paymentMethodId) : $this->paymentMethodId)."</div>\n";
		$htmlCode .= '	<div class="paymentmethods_paymentMethod">'.(($escapeHTML===true) ? htmlspecialchars($this->paymentMethod) : $this->paymentMethod)."</div>\n";
		$htmlCode .= "</div>\n";
		return $htmlCode;
	}
	/*
	public function getData($where) {
		$rows = $this->dao->getData($where);
		return $rows;
	}*/


	public static function loadAll(){
		$paymentmethods = new Paymentmethods();
		$rows = $paymentmethods->dao->getData("");
		$paymentmethodss = array();
		for ($index = 0; $index < sizeof($rows); $index++) {
			$d = new Paymentmethods();
			$d->init($rows[$index]);
			array_push($paymentmethodss,$d);
		}
		return $paymentmethodss;
	}
	
	public static function loadByPaymentMethod($paymentMethod){
		$paymentmethods = new Paymentmethods();
		$rows = $paymentmethods->dao->getData("`paymentMethod`='$paymentMethod'");
		$paymentmethodss = array();
		for ($index = 0; $index < sizeof($rows); $index++) {
			$d = new Paymentmethods();
			$d->init($rows[$index]);
			array_push($paymentmethodss,$d);
		}
		return $paymentmethodss;
	}


	/**
	 * Load the Paymentmethods uniquely by its primary key.
	 * @param paymentMethodId the primary key
	 * @return Paymentmethods Instance of {@link Paymentmethods}
	 */
	public static function loadUnique($paymentMethodId){
		$paymentmethods = new Paymentmethods();
		$rows = $paymentmethods->dao->getData("`paymentMethodId`='$paymentMethodId'");
		$paymentmethods->init($rows[0]);
		return $paymentmethods;
	}


	/**
	 * Insert this object into the DB
	 * @return number new id (auto increment value) genereated
	 */
	public function insert(){
		$list = array("paymentMethodId"=>$this->paymentMethodId, "paymentMethod"=>$this->paymentMethod);
		return $this->dao->insertRecord($list);
	}


	/**
	 * Update this object into the DB
	 * @return number the number of updated records
	 */
	public function update(){
		$list = array("paymentMethodId"=>$this->paymentMethodId, "paymentMethod"=>$this->paymentMethod);
		$where = "`paymentMethodId`='$paymentMethodId'";
		return $this->dao->updateRecord($list,$where);
	}


	/**
	 * Initialize the business object with data read from the DB.
	 */
	public function initPOST(){
		if (isset($_POST['paymentMethodId'])){
			$this->paymentMethodId = $_POST['paymentMethodId'];
		}
		if (isset($_POST['paymentMethod'])){
			$this->paymentMethod = $_POST['paymentMethod'];
		}
	}


	/**
	 * Initialize the business object with data read from the DB.
	 */
	public function initGET(){
		if (isset($_GET['paymentMethodId'])){
			$this->paymentMethodId = $_GET['paymentMethodId'];
		}
		if (isset($_GET['paymentMethod'])){
			$this->paymentMethod = $_GET['paymentMethod'];
		}
	}


	/**
	 * Returns the value from the database field paymentMethodId.
	 * In the database the field paymentMethodId is of type int.
	 * The database field is NOT nullable.
	 * @return String the value of the field
	 */
	public function getPaymentMethodId(){
		return $this->paymentMethodId;
	}


	/**
	 * Set the value from the database field paymentMethodId.
	 * In the database the field paymentMethodId is of type int.
	 * The database field is NOT nullable.
	 * @param paymentMethodId String with the value for the field to be set
	 */
	public function setPaymentMethodId($paymentMethodId){
		$this->paymentMethodId = $paymentMethodId;
	}


	/**
	 * Returns the value from the database field paymentMethod.
	 * In the database the field paymentMethod is of type varchar.
	 * The database field is  nullable.
	 * @return String the value of the field
	 */
	public function getPaymentMethod(){
		return $this->paymentMethod;
	}


	/**
	 * Set the value from the database field paymentMethod.
	 * In the database the field paymentMethod is of type varchar.
	 * The database field is  nullable.
	 * @param paymentMethod String with the value for the field to be set
	 */
	public function setPaymentMethod($paymentMethod){
		if(strlen($paymentMethod) > 45) throw new Exception("paymentMethod does not allow strings longer than 45 characters. The submitted string contains ".strlen($paymentMethod)." characters.");
		$this->paymentMethod = $paymentMethod;
	}
}
?>